package com.etrans.util;

import java.text.SimpleDateFormat;
import org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder;
import org.springframework.security.authentication.encoding.ShaPasswordEncoder;

/**
 * The Class OnewayEncoder.
 */
public class OnewayEncoder {

	/**
	 * Encode password.
	 * 
	 * @param plainPassword the plain password
	 * @param salt the salt
	 * @return the string
	 */
	public static String encodePassword(String plainPassword, String salt) {
		MessageDigestPasswordEncoder encoder = null;
		encoder = new ShaPasswordEncoder(256);
		return encoder.encodePassword(plainPassword, salt);
	}
	
	/**
	 * 默认加密
	 * @param plainPassword
	 * @param salt
	 * @return
	 */
	public static String encodePassword(String plainPassword) {
		return encodePassword(plainPassword, "");
	}
	
	/**
	 * The main method.
	 * 
	 * @param args the arguments
	 */
	public static void main(String[] args) {
		SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss'Z'");
		//String time = df.format(new Date());
		//String user = "wsuser";
		//String rannum = "1234567890";
		String salt = "";
		//System.out.println(time);
		System.out.println(encodePassword("428527"));
	}
}
